I am neither especially clever nor especially gifted.I am only very, very curious.

5mouth Archive Project

Stay Hungry · Stay Foolish




IKEv2 GRE over IPSec VPN - 5mouth

IKEv2 GRE over IPSec VPN

介绍

GRE over IPSec VPN主要用来解决传统 Site to Site面临的一些问题。

  1. 站点和站点之间不能运行路由协议。
  2. 没有“接口”概念使得QOS,ACL无法应用在IPsec VPN上。
  3. 当网络变的复杂的时候需要配置很多个“感兴趣数据流”使得ACL配置复杂。

解决上面3个棘手的问题方法是通过GRE over IPSec VPN或VTI(SVTI、DVTI),VTI不在本文讨论范围之内,本文主要解释GRE over IPSec VPN。
GRE我们都了解是一种三层的隧道技术,GRE可以很好的传递组播数据流,使得站点和站点之间运行动态路由协议成为可能。另外GRE提供了 interface tunnel ,使得QOS、ACL这些基于接口应用的服务得以实现。GRE提供接口,我们只需要把流量引入到tunnel接口里面即可,而不需要逐条配置感兴趣数据流,使得配置得到了简化,网络更易控制。

配置(关键配置)

拓扑图如下:
                                192.168.1.2          192.168.1.3    
                                  ----------Tunnel 1---------
                                  |                         |
    10.1.1.1                      |                         |                     40.1.1.1
     +-----+12.1.1.1           +--\--+23.1.1.2           +--\--+34.1.1.3           +-----+
     | R1  |--------F0/0-------| R2  |--------F0/1-------| R3  |--------F0/0-------| R4  |
     +-----+           12.1.1.2+-----+           23.1.1.3+-----+           34.1.1.4+-----+
R2配置:
crypto ikev2 proposal ikev2-proposal 
 encryption aes-cbc-256
 integrity sha512
 group 16
!
crypto ikev2 policy ikev2-policy 
 match fvrf any
 proposal ikev2-proposal
!
crypto ikev2 keyring ikev2-keyring
 peer ccie43413
  address 23.1.1.3
  pre-shared-key local ccie43413
  pre-shared-key remote ccie43413
 !
!
!
crypto ikev2 profile ikev2-profile
 match identity remote address 23.1.1.3 255.255.255.255 
 authentication remote pre-share
 authentication local pre-share
 keyring local ikev2-keyring
!
interface Tunnel1
 ip address 192.168.1.2 255.255.255.0
 ip ospf 1 area 0
 tunnel source FastEthernet0/1
 tunnel destination 23.1.1.3
!
!
interface FastEthernet0/1
 ip address 23.1.1.2 255.255.255.0
 speed auto
 duplex auto
 crypto map ikev2-map
!

GRE over IPSecVPN流程分析

流程图来自于此1

                                             Packet Flow Though Tunnel Interface                                               
                                                             R2                                                                  
                       +---------------------------------------------------------------------------+                           
                       |                                                                           |                           
FastEthernet0/0        |         +----------------+                    +----------------+          |   FastEthernet0/1         
IP Addr:12.1.1.2/24 /--|--\      |Route Lookup    |                    |Route Lookup    |      /---|--\IP Addr:23.1.1.2/24     
------------------->|Input|----->|                |                    |                |----->|Output|-------------------    
                    \--|--/      |Yields ifc: Tun1|                    |Yields ifc: Tun1|      \---|--/                       
                       |         +------|---------+                    +----------------+          |                           
                       |                |                                                         |                           
                       |                |                                      |                   |                           
                       |               /-\                                     |                   |                           
                       |               |T|  +-----------------------+          |                   |                           
                       |               |u|  |Tunnel1                |          |                   |                           
                       |               |n|  |IP addr: 192.168.1.2/24|          |                   |                           
                       |               |n|  |Source: FastEthernet0/1|          |                   |                           
                       |               |e|  |Destination: 23.1.1.3  |          |                   |                           
                       |               |l|  +-----------------------+          |                   |                           
                       |               \-/                                     |                   |                           
                       |                |                              +-------------+             |                           
                       |                |----------------------------->|Encapsulation|             |                           
                       |                                               +-------------+             |                           
                       +---------------------------------------------------------------------------+                           

1.数据包通过FastEthernet0/0接口进入。
【IP.Dst40.1.1.1】【IP.Src10.1.1.1】【Date】

2.目的路由查找,去往40.1.1.1目的地址的路由下一跳是tunnel接口。

3.数据包移交给tunnel接口进行封装操作。

4.在封装期间产生新的IP数据包。
Original Packet:【IP.Dst40.1.1.1】【IP.Src10.1.1.1】【Date】
                    ||
                    V
Encapsulated Packet:【IP.Dst23.1.1.3】【IP.Src23.1.1.2】【GRE】【IP.Dst40.1.1.1】【IP.Src10.1.1.1】【Date】

5.新的数据包再次执行路由查找。

6.目的路由查找,去往23.1.1.3目的路由的下一跳是FastEthernet0/1接口,###匹配crypto map策略执行ipsec vpn流程

7.执行完成ipsec vpn的数据包将从FastEthernet0/1接口转发出去。

注:如果crypto map 应用在tunnel接口上,那么当完成GRE封装之后就直接匹配crypto map直接进行ipsec vpn流程。

附录

除了之前介绍的GRE over IPSec VPN的配置方法,如下的配置方法也能完成同样的效果。 这种被称之为“Tunnel Protection and Crypto Sockets”,可参见23,在此不涉及。

crypto ikev2 proposal ikev2-proposal 
  encryption aes-cbc-256
  integrity sha512
  group 16
 !
 crypto ikev2 policy ikev2-policy 
  match fvrf any
  proposal ikev2-proposal
 !
 crypto ikev2 keyring ikev2-keyring
 peer 23.1.1.3
 address 23.1.1.3
 pre-shared-key local ccie43413
 pre-shared-key remote ccie43413
 !
 crypto ikev2 profile ikev2-profile
 match identity remote address 23.1.1.3 255.255.255.255
 identity local address 23.1.1.2
 authentication remote pre-share
 authentication local pre-share
 keyring local ikev2-keyring
 !
 crypto ipsec transform-set ipsec-transform esp-aes 256 esp-sha512-hmac
 mode tunnel
 !
 crypto ipsec profile ipsec-profile 
 set transform-set ipsec-transform
 set ikev2-profile ikev2-profile
 !
 interface Tunnel1
 tunnel protection ipsec profile ipsec-profile

参考文献


  1. IKEv2 IPsec Virtual Private Networks Understanding and Deploying:Figure 4-7 Packet Flow Though Tunnel Interface
  2. Sharing IPSec with Tunnel Protection
  3. Dynamic Multipoint VPN Configuration Guide, Cisco IOS XE Release 3S Sharing IPsec with Tunnel Protection